package org.simpleframework.mvc.render.impl;

import org.simpleframework.mvc.RequestProcessorChain;
import org.simpleframework.mvc.render.ResultRender;

import javax.servlet.http.HttpServletResponse;

/**
 * 内部异常渲染器
 *
 * @author: Oliver
 * @time: 2020/12/29/19:59
 */
public class InternalErrorResultRender implements ResultRender {
    private String errorMessage;

    public InternalErrorResultRender(String message) {
        this.errorMessage = message;
    }

    /**
     * 抛出异常信息
     *
     * @param chain 请求执行链
     * @throws Exception
     */
    @Override
    public void render(RequestProcessorChain chain) throws Exception {
        HttpServletResponse response = chain.getResponse();
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, errorMessage);
    }
}
